/*
 * shibeDogeAdmissionsTool.js
 * 
 * A collection of functions for the control of the shibeDogeAdmissionsTool. Includes
 * the document.onready function and various other functions, such as event handlers, that call
 * functions in other files.
 *
 * AUTHOR
 *  PREBEN INGVALDSEN
 *    
 */

var cs441ShibeDoge = cs441ShibeDoge || {};

/*
 * initializeTool
 * 
 * Called when the DOM has been fully loaded, this function shows the summary 
 * data tables and populates them with summary data for all applicants across
 * the United States
 */
cs441ShibeDoge.initializeTool = function() {
	cs441ShibeDoge.geocoder = new google.maps.Geocoder();
	//Create the Data Object and scrape the data
	cs441ShibeDoge.dataObject = {	} || cs441ShibeDoge.dataObject;
	cs441ShibeDoge.scrapeData();
	cs441GoogleMapsViz.addEvent(document.getElementById('regionSelectButton'), 'click', function() {
		cs441ShibeDoge.selectRegion();
	});
	cs441GoogleMapsViz.addEvent(document.getElementById('state'), 'change', function() {
		cs441ShibeDoge.updateCityDropdown();
	});
	cs441GoogleMapsViz.addEvent(document.getElementById('city'), 'change', function() {
		cs441ShibeDoge.displayRegionSelectSubmitButton();
	});
	cs441GoogleMapsViz.addEvent(document.getElementById('showAllButton'), 'click', function() {
		cs441ShibeDoge.deselectAndShowAllApplicants();
	});
	cs441GoogleMapsViz.addEvent(document.getElementById('filterSelectButton'), 'click', function() {
		cs441ShibeDoge.selectFilter();
	});
	cs441GoogleMapsViz.addEvent(document.getElementById('filterResetButton'), 'click', function() {
		cs441ShibeDoge.resetFilter();
	});
}

//Kick off the initialization of our admissions tool
window.onload = function() { cs441ShibeDoge.initializeTool() };
